<?php
class MiceController extends Apps_Controller_Action_Default {
    public function generalAction() {
         $tbEvent = new M_DbTable_Event();
         $listMice = $tbEvent->listMice($tbEvent::TYPE_GENERAL);
         $this->setPagination($listMice, $this->_request, 5);
    }
    public function incentiveAction() {
         $tbEvent = new M_DbTable_Event();
         $listMice = $tbEvent->listMice($tbEvent::TYPE_INCENTIVE);
         $this->setPagination($listMice, $this->_request, 5);
    }
    public function meetingConferenceAction() {
         $tbEvent = new M_DbTable_Event();
         $listMice = $tbEvent->listMice($tbEvent::TYPE_MEETING_CONFERENCE);
         $this->setPagination($listMice, $this->_request, 5);
    }
    public function eventAction() {
         $tbEvent = new M_DbTable_Event();
         $listMice = $tbEvent->listMice($tbEvent::TYPE_EVENT);
         $this->setPagination($listMice, $this->_request, 5);
    }

    public function detailAction() {
        $id = intval($this->_request->getParam('id'));
        $t  = intval($this->_request->getParam('t'));
        
        $eventModel = new M_Event();
        $event = $eventModel->getEventById($id)->query()->fetch();
        if(!$id || !$t || !$event) {
            $this->_redirect('');
        } else {
            $this->view->event = $event;

            $this->view->otherLink = $eventModel->listOtherMice($t, $id)->query()->fetchAll();
        }

        $type = array(
                M_DbTable_Event::TYPE_GENERAL   	        => 'General_Information',
                M_DbTable_Event::TYPE_INCENTIVE	            => 'Incentives',
                M_DbTable_Event::TYPE_MEETING_CONFERENCE	=> 'Meetings_&_Conferences',
                M_DbTable_Event::TYPE_EVENT	                => 'Events'
                );
        $this->view->labelType = isset($type[$t]) ? $type[$t] : $type[M_DbTable_Event::TYPE_GENERAL];
        $this->view->t = $t;
        
        //meta tag
        $tbVctSetting = new M_DbTable_VctSetting();
        $vctSetting   = $tbVctSetting->getMetaTag();
        $this->_page_meta_keywords    = $event['meta_keyword'] ? $event['meta_keyword'] : ($vctSetting['meta_keyword'] ? $vctSetting['meta_keyword'] : $this->_default_keyword);
        $this->_page_meta_description = $event['meta_description'] ? $event['meta_description'] : ($vctSetting['meta_description'] ? $vctSetting['meta_description'] : $this->_default_description);
        $this->_page_title 	  		  = $event['header_title'] ? $event['header_title'] : ($vctSetting['header_title'] ? $vctSetting['header_title'] : $this->_default_header_title);
    }
}